<!--
////////////////////////////////////////////////////////////////////////////////
//
//  Copyright 2007 humbroll.  All rights reserved.
//
////////////////////////////////////////////////////////////////////////////////
-->

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>OpenBrain flyout</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="css/flyout.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="core/js/core.js"></script>
    <script type="text/javascript" src="js/gadget.js"></script>
	<script type="text/javascript" src="js/flyout.js"></script>
	<script type="text/javascript" src="js/main.js"></script>
	<script type="text/javascript" src="js/ajaxEngine.js"></script>
	<script type="text/javascript" src="js/queryEngine.js"></script>
	<script type="text/javascript" src="js/auth.js"></script>
	<script src="js/alert.vbs" type="text/vbscript"></script>
	<script type="text/javascript">
		var m_gadget = System.Gadget.document.parentWindow;
		var M_OPENID = m_gadget.M_OPENID;
		var M_USERKEY = m_gadget.M_USERKEY;
		var m_appKeyName = m_gadget.M_APPKEYNAME;
		var m_ajaxEngine = m_gadget.M_AJAXENGINE;
		var m_queryEngine = new queryEngine();
		var m_temp = "";
		//event method=========================================================
		function onAddOkClick(){
			var m_query = m_queryEngine.makeAddPageQuery();
			var m_title = document.getElementById('title').value;
			var m_content = document.getElementById('content').value;
			var m_content_xml = m_queryEngine.makeAddXMLPageQuery(m_title,m_content);
			m_ajaxEngine.openXHR("POST",m_query,addResult,m_content_xml);
		}
		function onAddCancelClick(){
			document.getElementById('title').value = "";
			document.getElementById('content').value = "";
			doProcFlyoutClose();
		}
		//=====================================================================

		//callback method======================================================
		function addResult(p_result){
			var m_error = errorHandler(p_result);
			if(m_error == "noerror"){
				alert("SUCCESS ADD!");
				doProcFlyoutClose();
			}
			else{
				alert(m_error);
				doProcFlyoutClose();
			}
		}
		//=====================================================================
	</script>
</head>
<body onload="loadFlyout();" dir="ltr" style="overflow:auto;">
		<div id="addlayout" style="display:block;">
				<label for="title" >Title : </label><input type="text" id="title" name="title" size=50 ></input>
				<br/>
				<fieldset>
					<legend>Content</legend>
					<textarea rows="20" cols="50" id="content" name="content"></textarea>					
				</fieldset>
				<div align="right">
					<button id="addok" name="addok" onclick="onAddOkClick();" style="width:100"><b>Ok</b></button>	
					<button id="addcancel" name="addcancel" onclick="onAddCancelClick();" style="width:100"><b>Cancel</b></button>
				</div>
		</div>
</body>
</html>